package com.nanbei.statisticsService.scheduled;

import com.nanbei.commonUntil.R;
import com.nanbei.statisticsService.service.StatisticsDailyService;
import com.nanbei.statisticsService.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class ScheduledTask {

    @Autowired
    private StatisticsDailyService statisticsDailyService;

    /**
     * 每天凌晨一点需要执行的接口
     * @return
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public R scheduled(){
        String day = DateUtil.formatDate(DateUtil.addDays(new Date(), -1));
        statisticsDailyService.registerCount(day);
        return R.ok();
    }
}
